package com.ojoin.trade.common.utils.json;

import java.io.IOException;

import org.apache.commons.lang3.StringUtils;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.ojoin.trade.common.utils.CommonUtils;
/**
 * 输出掩码样式
 * @author huanggc
 *
 */
public  class selfDefineMobileMaskSerializer extends JsonSerializer<String>{  
        @Override  
        public void serialize(String cardNo, JsonGenerator gen, SerializerProvider provider)  
                throws IOException, JsonProcessingException { 
        	if(StringUtils.isNotEmpty(cardNo)&&cardNo.length()>8){
        		String maskmobile = CommonUtils.maskMobile(cardNo);
				gen.writeString(maskmobile);  
        	}else{
        		gen.writeString(cardNo);
        	}
        }
    }  